{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 1、导入必要的工具包"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np  # 矩阵操作\n",
    "import pandas as pd # SQL数据处理\n",
    "\n",
    "from sklearn.metrics import r2_score  #评价回归预测模型的性能\n",
    "\n",
    "import matplotlib.pyplot as plt   #画图\n",
    "import seaborn as sns\n",
    "\n",
    "# 图形出现在Notebook里而不是新窗口\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 2、数据探索"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>season</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   season  mnth  holiday  weekday  workingday  weathersit      temp     atemp  \\\n",
       "0       1     1        0        6           0           2  0.344167  0.363625   \n",
       "1       1     1        0        0           0           2  0.363478  0.353739   \n",
       "2       1     1        0        1           1           1  0.196364  0.189405   \n",
       "3       1     1        0        2           1           1  0.200000  0.212122   \n",
       "4       1     1        0        3           1           1  0.226957  0.229270   \n",
       "\n",
       "        hum  windspeed   cnt  \n",
       "0  0.805833   0.160446   985  \n",
       "1  0.696087   0.248539   801  \n",
       "2  0.437273   0.248309  1349  \n",
       "3  0.590435   0.160296  1562  \n",
       "4  0.436957   0.186900  1600  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# path to where the data lies\n",
    "#dpath = './data/'\n",
    "data = pd.read_csv(\"day.csv\")\n",
    "\n",
    "#通过观察前5行，了解数据每列（特征）的概况\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 在这里尝试过直接将提前分割的11年12年数据作为训练集与测试集输入，发现后面会对train 数据集 无法读取"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  2.2 数据基本信息\n",
    "样本数目、特征维数\n",
    "每个特征的类型、空值样本的数目、数据类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(731, 11)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2.3 数据探索\n",
    "请见另一个文件：数据探索.ipynb\n",
    "\n",
    "对数据的探索有助于我们在第三步中根据数据的特点选择合适的模型类型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "y = data['cnt'].values\n",
    "X = data.drop('cnt', axis = 1)\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(365, 10)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#将数据分割训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=0, test_size=0.5)\n",
    "X_train.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 请问老师如何将数据按属性进行分类构建样本？"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 数据预处理/特征工程"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:444: DataConversionWarning: Data with input dtype int64 was converted to float64 by StandardScaler.\n",
      "  warnings.warn(msg, DataConversionWarning)\n"
     ]
    }
   ],
   "source": [
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 分别初始化对特征和目标值的标准化器\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征以及目标值进行标准化处理\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.transform(X_test)\n",
    "\n",
    "#对y做标准化不是必须\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 确定模型类型"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 尝试缺省参数的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[0.408048887921]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.278774755122]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[0.120281329933]</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.0445903814965]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.00995344188884]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-0.0151613107208]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.025647304746]</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[-0.093840275673]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-0.174367125162]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[-0.190990381063]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 coef     columns\n",
       "6    [0.408048887921]        temp\n",
       "0    [0.278774755122]      season\n",
       "7    [0.120281329933]       atemp\n",
       "3   [0.0445903814965]     weekday\n",
       "4  [0.00995344188884]  workingday\n",
       "2  [-0.0151613107208]     holiday\n",
       "1   [-0.025647304746]        mnth\n",
       "5   [-0.093840275673]  weathersit\n",
       "8   [-0.174367125162]         hum\n",
       "9   [-0.190990381063]   windspeed"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 模型评价"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.511348296736\n",
      "The r2 score of LinearRegression on train is 0.530558457121\n"
     ]
    }
   ],
   "source": [
    "print ('The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr))\n",
    "#训练集\n",
    "print ('The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekA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h555BFaWlr4zGc+w+zZsznttNP4xje+wb777suGDRuYPn06Tz75JEce\neeSmuh9++OF+1bEtvbaks6bzJkBL9ZXA+4DOX4NuAj5W9+okSTvMH/7wByZOnMjw4cN58cUX+cAH\nPgDUQvree+9l0qRJTJ48maeffprFixczYcIEfvnLX/KlL32Jhx56iGHDhm22v8cee4xp06bR1tbG\n7rvvzqc+9alea8hMLr74Yo488kje//73s3z5clauXLnZOkcffTQ33HADHR0dPPXUU+y11179er8z\nZsxgjz32YMSIEYwcOZKVK1cyZ84c5s2bx9FHH83EiROZM2cOzzzzDAC33347kydPZtKkSSxcuJBf\n//rXm/bVl/fWH326Jx0RQyJiPvA8cB/wr8BLmbm+WmUZMHpQKpQk7RCd96SXLl3K66+/vumedGZy\n0UUXMX/+fObPn8+SJUs466yzOPjgg5k3bx4TJkzgoosu4tJLL91qnz19BGm33XZj48aNm/b/+uuv\nAzB79mxWrVrFvHnzmD9/Pvvtt99WnzM+7rjjePDBBxk9ejSnnnoqN998c7/e7x577LHp9ZAhQ1i/\nfj2Zyemnn77pvf7mN7+ho6ODZ599lssvv5w5c+bw5JNPMmPGjM3q2nPPPftVQ2/69HR3Zm4AJkbE\nPsBdwKHdrdbdthExC5gFMHbs2H6WKe0c+vpEbr2f3JXqadiwYVx55ZXMnDmT8847j+OPP56vfvWr\nnHzyybS2trJ8+XJaWlpYv349++67L6eccgqtra3ceOONm+3nXe96FxdeeCGrV69m77335o477uCo\no44Cavdx582bxyc/+Unuvvtu3njjDaDWZT5y5EhaWlq4//77Wbp067/ouHTpUkaPHs0555zDK6+8\nwhNPPMFpp51Wl/c+ffp0Zs6cyec+9zlGjhzJiy++yNq1a1mzZg177rknw4YNY+XKldxzzz1Mmzat\nLsfclu36CFZmvhQRDwDHAPtExG5Va3oM8LsetrkWuBagvb292yCXJG2u0b/ITZo0iaOOOopbb72V\nU089lUWLFjF16lSg9pDXLbfcwpIlS/jiF7/Im970JlpaWrjmms0fSxo1ahQdHR1MnTqVUaNGM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ZeC1w7gOPsMBExNzPbG11Hs/L8N57X\noLE8/41X2jUYSHf3MuCALtNjgN8NrBxJktRpICH9T8A7ImJ8ROwOfBr4eX3KkiRJ/e7uzsz1EXEB\n8A/AEOD6zFxYt8oaY6folt+Fef4bz2vQWJ7/xivqGvT7wTFJkjS4HHFMkqRCGdKSJBXKkN5CRFwW\nEU9HxJMRcVdE7NPomppJRHwiIhZGxMaIKOZjELs6h/htrIi4PiKej4gFja6lWUXEARFxf0Qsqn4G\nXdjomsCQ7s59wBGZeSTwf4GLGlxPs1kA/CfgwUYX0iwc4rcINwInNLqIJrce+EJmHgocA5xfwv8D\nQ3oLmXlvZq6vJn9F7fPf2kEyc1Fmljwq3a7IIX4bLDMfBF5sdB3NLDNXZOYT1eu1wCJgdGOrMqR7\ncyZwT6OLkAbZaOC3XaaXUcAPJ6lRImIcMAl4rLGVDGxY0J1WRPwSeGs3i76SmXdX63yFWvfH7B1Z\nWzPoy/nXDtWnIX6lZhARrcBPgc9m5ppG19OUIZ2Z79/W8og4HfgIMD39IHnd9Xb+tcM5xK8EREQL\ntYCenZk/a3Q9YHf3ViLiBOBLwImZ+Wqj65F2AIf4VdOLiACuAxZl5hWNrqeTIb21q4C9gPsiYn5E\n/E2jC2omEfHxiFgGTAV+ERH/0OiadnXVg5KdQ/wuAm7fBYb43alExE+AR4FDImJZRJzV6Jqa0LHA\nqcD7qp/98yPiw40uymFBJUkqlC1pSZIKZUhLklQoQ1qSpEIZ0pIkFcqQliSpUIa0JEmFMqQlSSrU\n/wen1CFYylxLhwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1038b8a90>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Histogram of Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 残差分布与高斯分布较匹配，左侧残差较大，可能是数据中有12个数据的y值为最小值，有噪声。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJztnXl4lOXV/z9nJkMIsoRVJQpYtVhBdhVFK1otuAMuqLSv\nuL6urRsVcUHtogUV377+SrVQF4q7yKtQRQW1biA7UYHWpSIRWSQBspBMkvP7Y2biJHlm5kkyM88k\nOZ/rmiuzPPPcZyYz37nvc859jqgqhmEYqcDntQGGYbRcTGAMw0gZJjCGYaQMExjDMFKGCYxhGCnD\nBMYwjJRhAmMYRsowgTEMI2WYwBiGkTKyvDagIXTr1k379OnjtRmG0epZuXLlDlXtnui4ZiUwffr0\nYcWKFV6bYRitHhH52s1xtkQyDCNlmMAYhpEyPBMYEWkrIh+LyFoR+VRE7vHKFsMwUoOXPphy4CRV\nLRaRAPC+iLymqks9tMkwjCTi2QxGQxSHbwbCFytOYxgeUFFRkZLzeuqDERG/iKwBtgFvquoyh2Ou\nFJEVIrJi+/bt6TfSMFo469atY+jQoTz99NNJP7enAqOqVao6CDgAOEpE+jsc85iqDlPVYd27Jwy7\nG4bhkurqah566CGOPPJIduzYQdeuXZM+RkZEkVS1CHgHGO2xKYbRKti8eTOnnHIKN998M6eeeirr\n1q1j1KhRSR/HyyhSdxHJDV/PAU4GNnhlj2G0JpYvX86yZcuYNWsWL7/8MqlaHXgZRdofeFJE/ISE\n7nlVXeChPYbRotm1axcffvghp556KmPHjuXLL7+kR48eKR3TM4FR1XXAYK/GN4zWxHvvvccvf/lL\ntm/fztdff023bt1SLi6QIT4YwzBSQ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x/wvKrem5Rzt1SBMQzDe1rsEskwDO8xgTEMI2WYwBiGkTJMYAzDSBkmMIZh\npIxmnWhnJBcR6QosDt/cD6gCtodvHxXeQ5RumxYB54b36hjNDAtTG46IyN1Asao+UOd+IfS5qXZ8\nYvLGT8s4RmqxJZKREBE5JLyf6S/AKuBAESmKevwCEZkVvr6viMwTkRXhGiPDHc53ebg2zqJwfZg7\nYoyzv4hsjsoyvSRcV2etiDzudjzDO2yJZLjlcOASVb1KROJ9bv4ETFPVpeEdwgsAp41zR4XvrwCW\ni8gCoDh6HIDQRAZEZCChLRfHqupOEenSwPEMDzCBMdzyhaoud3HcyUDfiDAAnUUkR1XL6hy3SFUL\nAURkPnAc8HqccU4CnlPVnQCRvw0Yz/AAExjDLSVR16upXX6hbdR1wZ1DuK7zL3K7pO6BUed1chi6\nHc/wAPPBGA0m7HgtFJFDRcQHjI16+C3g2sgNERkU4zQ/F5FcEWlHqLLdBwmGfQu4ILI0iloiuR3P\n8AATGKOx3EpoSbOYUK2XCNcCI8LO2M+AK2I8/31CdXpWA8+o6pp4g6nqOmAa8M9w5bXpDRzP8AAL\nUxtpR0QuB/qr6g1e22KkFpvBGIaRMmwGYxhGyrAZjGEYKcMExjCMlGECYxhGyjCBMQwjZZjAGIaR\nMv4/RjF0ozkNtQUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1373c358>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True price')\n",
    "plt.ylabel('Predicted price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 预测效果较好，比较符合线性模型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.6/site-packages/sklearn/utils/validation.py:547: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.27685069, -0.02717825, -0.01481402,  0.0451053 ,  0.00973277,\n",
       "       -0.09399512,  0.39286527,  0.1330594 , -0.17533351, -0.18973398])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性模型，随机梯度下降优化模型参数\n",
    "# 随机梯度下降一般在大数据集上应用，其实本项目不适合用\n",
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "# 使用默认配置初始化线\n",
    "sgdr = SGDRegressor(max_iter=1000)\n",
    "\n",
    "# 训练：参数估计\n",
    "sgdr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "#sgdr_y_predict = sgdr.predict(X_test)\n",
    "\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of SGDRegressor on test is 0.512008917074\n",
      "The value of default measurement of SGDRegressor on train is 0.530526236185\n"
     ]
    }
   ],
   "source": [
    "# 使用SGDRegressor模型自带的评估模块(评价准则为r2_score)，并输出评估结果\n",
    "print ('The value of default measurement of SGDRegressor on test is', sgdr.score(X_test, y_test))\n",
    "print ('The value of default measurement of SGDRegressor on train is', sgdr.score(X_train, y_train))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 较缺省参数回归预测结果基本相同，相差的原因可能是由于数据量较小"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 正则化的线性回归（L2正则——> 岭回归）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.511949006147\n",
      "The r2 score of RidgeCV on train is 0.530040612847\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "#n_alphas = 20\n",
    "#alphas = np.logspace(-5,2,n_alphas)\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge))\n",
    "print ('The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "###  相比于线性二乘较为优秀"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 可视化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAZIAAAEKCAYAAAA4t9PUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl8FfW9//HXJxv7ngTZ90VUZAmICyioLbUWbW1FxAU3\nrlqLbe+12tvFR217e62/1lart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GtzaPy1Y14/YbS3ilQEzgufTgPgb8B16Po9YeAGkA38yswFAKdA7rn0BsVvViIRKQSKS\nmCN9ydTRvnxqH7F7aGFm3YD/Aoa4+zYze+zQukrE38OoOPizlC/+7/6A2D3OTiU2wrA/rn3DoAaR\nUGloSyQx7wJjzSw1mLcYQezmiu8T++KnFDNrS+zrVg9ZDvQMnjcH9gA7gnZfO8L7pBC7+y/A5cH2\nj6YFsCk4IrqS2NfnHtKb5Lj7s9RxOiIRScxzxOY/FhI7SviRu39uZn8DziX2A3sVsW+m2xH0eYlY\nsLzh7gvN7GNid4ddC3xwhPfZA5xkZvOC7YytpK4Hgb+Z2XeI3Z13T9y6kUENIqHS3X9FqsjMmnrs\nW/HaEDtKOTMImUbEfrifGcytJLKt3e7etJrqehe4yN23Vcf2RI5ERyQiVfeimbUEMoBfuvvnAO6+\nz8zuJPbd2OtrsqBg+O33ChGpCToiERGRKtFku4iIVImCREREqkRBIiIiVaIgERGRKlGQiIhIlShI\nRESkSv4/lOHrilYGoNEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a13838d68>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 10.0\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[0.408048887921]</td>\n",
       "      <td>[0.304959085785]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.278774755122]</td>\n",
       "      <td>[0.252311886494]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[0.120281329933]</td>\n",
       "      <td>[0.219206604913]</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.0445903814965]</td>\n",
       "      <td>[0.0446416916181]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.00995344188884]</td>\n",
       "      <td>[0.0104167780659]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-0.0151613107208]</td>\n",
       "      <td>[-0.0144866720491]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.025647304746]</td>\n",
       "      <td>[-0.00290452433163]</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[-0.093840275673]</td>\n",
       "      <td>[-0.0984789361199]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-0.174367125162]</td>\n",
       "      <td>[-0.165727449477]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[-0.190990381063]</td>\n",
       "      <td>[-0.183197779586]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "              coef_lr           coef_ridge     columns\n",
       "6    [0.408048887921]     [0.304959085785]        temp\n",
       "0    [0.278774755122]     [0.252311886494]      season\n",
       "7    [0.120281329933]     [0.219206604913]       atemp\n",
       "3   [0.0445903814965]    [0.0446416916181]     weekday\n",
       "4  [0.00995344188884]    [0.0104167780659]  workingday\n",
       "2  [-0.0151613107208]   [-0.0144866720491]     holiday\n",
       "1   [-0.025647304746]  [-0.00290452433163]        mnth\n",
       "5   [-0.093840275673]   [-0.0984789361199]  weathersit\n",
       "8   [-0.174367125162]    [-0.165727449477]         hum\n",
       "9   [-0.190990381063]    [-0.183197779586]   windspeed"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 对于大部分数据来说，岭回归都起到了收缩的作用"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##  正则化的线性回归"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.506713574926\n",
      "The r2 score of LassoCV on train is 0.529080717905\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/anaconda3/lib/python3.6/site-packages/sklearn/linear_model/coordinate_descent.py:1094: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "#alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "#lasso = LassoCV(alphas=alphas)  \n",
    "lasso = LassoCV()  \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print ('The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso))\n",
    "print ('The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4XOV59/Hvrc3yLlsW3uV9BWyMxWoCDmENiQlJILhZ\nSYrbt4HkTUlTaHIlLW2ShmzNVhKS8tIsQMlGgRiMwRAMMWA5xrtly4tsWdZiS9YuSxrd7x8zUgYj\n22PsozOj+X2uay7NOfPMzH081vx0znPO85i7IyIiApARdgEiIpI8FAoiItJ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a+CSuOcs\nAtbFLX/R3YuAecAVZjavl/cZDPzZ3c8H/sibx8jKcvcLgf8bt74auDrW/kPA9+PaFwPvOPVNFTk1\nGhBP0tFlwCPuHgGqzOyPwAWx9b929y6g0sxeiHvOWKAmbvmW2JDVWbHH5hId+iReF/A/sfu/BH4X\n91j3/XVEgwggG/ihmZ0HRICZce2riQ4PIRIohYKko96Gaz7ReoBWIBfAzKYAnwcucPc6M3uo+7GT\niB9T5mjsZ4S//B5+jugYQfOJ7sW3xbXPjdUgEigdPpJ09BLwITPLjB3nvxx4HXgZ+ECsb2E0bx7+\nfBswPXZ/GNAM1MfaXX+c98kAuvsk/ir2+icyHDgY21P5KNGpKrvNJHVHQpUUoj0FSUe/J9pfsIHo\nX+9fcPdKM/st8C6iX747gNeA+thz/kA0JJ5z9w1mtp7oCKW7gVeO8z7NwNlmti72Oh86SV3/CfzW\nzG4GXog9v9s7YzWIBEqjpIrEMbMh7t5kZvlE9x4WxQJjINEv6kWxvohEXqvJ3YecobpeAm706Jzf\nIoHRnoLImz1lZnlADvCv7l4J4O6tZvYVovMH7+vLgmKHuL6jQJC+oD0FERHpoY5mERHpoVAQEZEe\nCgUREemhUBARkR4KBRER6aFQEBGRHv8faaMXuSHRmk4AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a13a7ab38>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.0143607603068\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style>\n",
       "    .dataframe thead tr:only-child th {\n",
       "        text-align: right;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: left;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.397009</td>\n",
       "      <td>[0.408048887921]</td>\n",
       "      <td>[0.304959085785]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.244220</td>\n",
       "      <td>[0.278774755122]</td>\n",
       "      <td>[0.252311886494]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.121475</td>\n",
       "      <td>[0.120281329933]</td>\n",
       "      <td>[0.219206604913]</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.032484</td>\n",
       "      <td>[0.0445903814965]</td>\n",
       "      <td>[0.0446416916181]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[0.00995344188884]</td>\n",
       "      <td>[0.0104167780659]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.005356</td>\n",
       "      <td>[-0.0151613107208]</td>\n",
       "      <td>[-0.0144866720491]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>[-0.025647304746]</td>\n",
       "      <td>[-0.00290452433163]</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-0.093258</td>\n",
       "      <td>[-0.093840275673]</td>\n",
       "      <td>[-0.0984789361199]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.154771</td>\n",
       "      <td>[-0.174367125162]</td>\n",
       "      <td>[-0.165727449477]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-0.175753</td>\n",
       "      <td>[-0.190990381063]</td>\n",
       "      <td>[-0.183197779586]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   coef_lasso             coef_lr           coef_ridge     columns\n",
       "6    0.397009    [0.408048887921]     [0.304959085785]        temp\n",
       "0    0.244220    [0.278774755122]     [0.252311886494]      season\n",
       "7    0.121475    [0.120281329933]     [0.219206604913]       atemp\n",
       "3    0.032484   [0.0445903814965]    [0.0446416916181]     weekday\n",
       "4    0.000000  [0.00995344188884]    [0.0104167780659]  workingday\n",
       "2   -0.005356  [-0.0151613107208]   [-0.0144866720491]     holiday\n",
       "1    0.000000   [-0.025647304746]  [-0.00290452433163]        mnth\n",
       "5   -0.093258   [-0.093840275673]   [-0.0984789361199]  weathersit\n",
       "8   -0.154771   [-0.174367125162]    [-0.165727449477]         hum\n",
       "9   -0.175753   [-0.190990381063]    [-0.183197779586]   windspeed"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAIABJREFUeJzt3Xl4XOV59/Hvrc3yLlsW3uV9BWyMxWoCDmENiQlJILhZ\nSYrbt4HkTUlTaHIlLW2ShmzNVhKS8tIsQMlGgRiMwRAMMWA5xrtly4tsWdZiS9YuSxrd7x8zUgYj\n22PsozOj+X2uay7NOfPMzH081vx0znPO85i7IyIiApARdgEiIpI8FAoiItJDoSAiIj0UCiIi0kOh\nICIiPRQKIiLSQ6EgIiI9FAoiItJDoSAiIj2ywi7gVI0aNconT54cdhkiIill3bp1h9y94GTtUi4U\nJk+eTHFxcdhliIikFDMrS6RdYIePzOxBM6s2s83HedzM7PtmVmpmG83s/KBqERGRxATZp/AQcN0J\nHr8emBG7LQPuD7AWERFJQGCh4O4vAbUnaHIj8HOPehXIM7OxQdUjIiInF+bZR+OB/XHL5bF1IiIS\nkjBDwXpZ1+vkDma2zMyKzay4pqYm4LJERNJXmKFQDkyMW54AVPTW0N0fcPcidy8qKDjpGVUiIvI2\nhRkKTwAfi52FdDFQ7+4HQ6xHRCTtBXadgpk9AiwGRplZOfAVIBvA3X8MLAfeDZQCLcBtQdUiIpLK\nIl3ON57Zzg3njmX+xLxA3yuwUHD3pSd53IFPB/X+IiL9xe6aJh54aTczRw8NPBQ09pGISJLbWF4P\nwLwJwwN/L4WCiEiS21h+hEE5mUwrGBL4eykURESS3MYD9ZwzbjiZGb2dyX9mKRRERJJYR6SLrRUN\nnNsHh45AoSAiktR2VjVxtLOrT/oTQKEgIpLUNh04AsC8CcGeddRNoSAiksQ2lNczNDeLSSMH9cn7\nKRRERJLYpvJ6zh0/nIw+6GQGhYKISNI62hlhe2XfdTKDQkFEJG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n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x1a1396bd30>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "alpha is: 0.0143607603068\n"
     ]
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
